package org.cpoy.ei.session;

import org.cpoy.eims.entity.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("studentPreviousAcadDetailsHome")
public class StudentPreviousAcadDetailsHome extends
		EntityHome<StudentPreviousAcadDetails> {

	@In(create = true)
	StudentHome studentHome;
	@In(create = true)
	AddressHome addressHome;

	public void setStudentPreviousAcadDetailsId(Integer id) {
		setId(id);
	}

	public Integer getStudentPreviousAcadDetailsId() {
		return (Integer) getId();
	}

	@Override
	protected StudentPreviousAcadDetails createInstance() {
		StudentPreviousAcadDetails studentPreviousAcadDetails = new StudentPreviousAcadDetails();
		return studentPreviousAcadDetails;
	}

	public void load() {
		if (isIdDefined()) {
			wire();
		}
	}

	public void wire() {
		getInstance();
		Student student = studentHome.getDefinedInstance();
		if (student != null) {
			getInstance().setStudent(student);
		}
		Address address = addressHome.getDefinedInstance();
		if (address != null) {
			getInstance().setAddress(address);
		}
	}

	public boolean isWired() {
		if (getInstance().getStudent() == null)
			return false;
		return true;
	}

	public StudentPreviousAcadDetails getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

}
